{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Prompt Engineering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "#os.environ[\"HUGGINGFACEHUB_API_TOKEN\"]\n",
    "openai_api_key = os.environ['OPENAI_API_KEY']\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Provide clear instructions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are an AI assistant that helps human by generating tutorials given a text.\n",
    "You will be provided with a text. If the text contains any kind of istructions on how to proceed with something, generate a tutorial in a bullet list.\n",
    "Otherwise, inform the user that the text does not contain any instructions.\n",
    "\n",
    "Text: \n",
    "\"\"\"\n",
    "\n",
    "instructions = \"\"\"\n",
    "To prepare the known sauce from Genova, Italy, you can start by toasting the pine nuts to then coarsely \n",
    "chop them in a kitchen mortar together with basil and garlic. Then, add half of the oil in the kitchen mortar and season with salt and pepper.\n",
    "Finally, transfer the pesto to a bowl and stir in the grated Parmesan cheese.\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sure, I can generate a tutorial based on the given text. Here's a bullet list on how to prepare the Genovese pesto sauce:\n",
      "\n",
      "- Toast the pine nuts on a pan until they are slightly browned.\n",
      "- Coarsely chop the toasted pine nuts, along with basil leaves and garlic cloves, using a kitchen mortar.\n",
      "- Add half of the olive oil into the kitchen mortar, and season the mixture with salt and pepper.\n",
      "- Grind the mixture until it becomes a smooth paste.\n",
      "- Transfer the pesto to a bowl, and stir in the grated Parmesan cheese.\n",
      "- You can add more olive oil to achieve the desired consistency for the sauce.\n",
      "- Your Genovese pesto sauce is now ready. It can be served with pasta, vegetables, or as a dip for bread. Enjoy!\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": instructions},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "As there are no instructions provided in the text you have given me, it is not possible to create a tutorial. May I have a different text to work with?\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": 'the sun is shining and dogs are running on the beach.'},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Split complext tasks into subtasks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are an AI assistant that summarize articles. \n",
    "To complete this task, do the following subtasks:\n",
    "\n",
    "Read the provided article context comprehensively and identified the main topic and key points\n",
    "Generated a paragraph summary of the current article context that captures the essential information and conveys the main idea\n",
    "Print each step of the proces.\n",
    "Article:\n",
    "\"\"\"\n",
    "\n",
    "article = \"\"\"\n",
    "Recurrent neural networks, long short-term memory and gated recurrent neural networks\n",
    "in particular, have been firmly established as state of the art approaches in sequence modeling and\n",
    "transduction problems such as language modeling and machine translation. Numerous\n",
    "efforts have since continued to push the boundaries of recurrent language models and encoder-decoder\n",
    "architectures.\n",
    "Recurrent models typically factor computation along the symbol positions of the input and output\n",
    "sequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\n",
    "states ht, as a function of the previous hidden state ht-1 and the input for position t. This inherently\n",
    "sequential nature precludes parallelization within training examples, which becomes critical at longer\n",
    "sequence lengths, as memory constraints limit batching across examples. Recent work has achieved\n",
    "significant improvements in computational efficiency through factorization tricks and conditional\n",
    "computation, while also improving model performance in case of the latter. The fundamental\n",
    "constraint of sequential computation, however, remains.\n",
    "Attention mechanisms have become an integral part of compelling sequence modeling and transduction models in various tasks, allowing modeling of dependencies without regard to their distance in\n",
    "the input or output sequences. In all but a few cases, however, such attention mechanisms\n",
    "are used in conjunction with a recurrent network.\n",
    "In this work we propose the Transformer, a model architecture eschewing recurrence and instead\n",
    "relying entirely on an attention mechanism to draw global dependencies between input and output.\n",
    "The Transformer allows for significantly more parallelization and can reach a new state of the art in\n",
    "translation quality after being trained for as little as twelve hours on eight P100 GPUs.\n",
    "\"\"\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"id\": \"chatcmpl-843xICFWzmnA7oic3XQEcaPABAknA\",\n",
      "  \"object\": \"chat.completion\",\n",
      "  \"created\": 1695979208,\n",
      "  \"model\": \"gpt-3.5-turbo\",\n",
      "  \"choices\": [\n",
      "    {\n",
      "      \"index\": 0,\n",
      "      \"finish_reason\": \"stop\",\n",
      "      \"message\": {\n",
      "        \"role\": \"assistant\",\n",
      "        \"content\": \"Summary: \\n\\nThe article discusses the use of recurrent neural networks, specifically long short-term memory and gated recurrent neural networks, in sequence modeling and transduction problems. These models have achieved great success but are limited by their inherently sequential nature. Attention mechanisms have become popular in addressing this issue but are usually used in conjunction with recurrent networks. The authors propose the Transformer, an architecture that relies solely on attention mechanisms instead of recurrence. The Transformer allows for greater parallelization and can achieve state-of-the-art results in machine translation after only twelve hours of training on eight GPUs. \\n\\nSteps:\\n1. The article discusses the success and limitations of recurrent neural networks in sequence modeling and transduction problems. \\n2. Attention mechanisms have become popular in addressing the limitations of recurrence but are usually used alongside recurrent networks. \\n3. The authors propose the Transformer, a model architecture that relies solely on attention mechanisms and allows for greater parallelization. \\n4. The Transformer can achieve state-of-the-art results in machine translation after only twelve hours of training on eight GPUs.\"\n",
      "      }\n",
      "    }\n",
      "  ],\n",
      "  \"usage\": {\n",
      "    \"completion_tokens\": 208,\n",
      "    \"prompt_tokens\": 407,\n",
      "    \"total_tokens\": 615\n",
      "  }\n",
      "}\n",
      "Summary: \n",
      "\n",
      "The article discusses the use of recurrent neural networks, specifically long short-term memory and gated recurrent neural networks, in sequence modeling and transduction problems. These models have achieved great success but are limited by their inherently sequential nature. Attention mechanisms have become popular in addressing this issue but are usually used in conjunction with recurrent networks. The authors propose the Transformer, an architecture that relies solely on attention mechanisms instead of recurrence. The Transformer allows for greater parallelization and can achieve state-of-the-art results in machine translation after only twelve hours of training on eight GPUs. \n",
      "\n",
      "Steps:\n",
      "1. The article discusses the success and limitations of recurrent neural networks in sequence modeling and transduction problems. \n",
      "2. Attention mechanisms have become popular in addressing the limitations of recurrence but are usually used alongside recurrent networks. \n",
      "3. The authors propose the Transformer, a model architecture that relies solely on attention mechanisms and allows for greater parallelization. \n",
      "4. The Transformer can achieve state-of-the-art results in machine translation after only twelve hours of training on eight GPUs.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": article},\n",
    "    ]\n",
    ")\n",
    "\n",
    "print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Summary: \n",
      "\n",
      "The article discusses the use of recurrent neural networks, specifically long short-term memory and gated recurrent neural networks, in sequence modeling and transduction problems. These models have achieved great success but are limited by their inherently sequential nature. Attention mechanisms have become popular in addressing this issue but are usually used in conjunction with recurrent networks. The authors propose the Transformer, an architecture that relies solely on attention mechanisms instead of recurrence. The Transformer allows for greater parallelization and can achieve state-of-the-art results in machine translation after only twelve hours of training on eight GPUs. \n",
      "\n",
      "Steps:\n",
      "1. The article discusses the success and limitations of recurrent neural networks in sequence modeling and transduction problems. \n",
      "2. Attention mechanisms have become popular in addressing the limitations of recurrence but are usually used alongside recurrent networks. \n",
      "3. The authors propose the Transformer, a model architecture that relies solely on attention mechanisms and allows for greater parallelization. \n",
      "4. The Transformer can achieve state-of-the-art results in machine translation after only twelve hours of training on eight GPUs.\n"
     ]
    }
   ],
   "source": [
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ask for justification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are an AI assistant specialized in generating essays shorter than 500 words.\n",
    "Given a statement, develop the essay the best you can.\n",
    "Once the essay is generated, provide clear justifications and explanations of the reasons behind the sentences you generated.\n",
    "\n",
    "Statement:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "statement = \"\"\"\n",
    "An introduction to mammals like chickens.\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mammals are a diverse group of animals that share certain characteristics such as giving birth to live young and producing milk to feed their offspring. However, not all animals traditionally thought of as mammals fit this description. One example of this is chickens, which are actually a type of bird. While chickens and other birds share some characteristics with mammals, such as the ability to regulate their own body temperature, they are not classified as mammals for several reasons.\n",
      "\n",
      "Firstly, chickens do not give live birth. Rather, they lay eggs from which their young hatch. Only mammals give live birth. Additionally, chickens do not produce milk as a means of feeding their young. Instead, baby chicks are fed through a process called internal yolk sac feeding while still inside the egg. Once hatched, they are provided food and water by their mother through a process called brooding. \n",
      "\n",
      "Moreover, mammals have certain anatomical structures that help distinguish them from birds. For example, mammals have three middle ear bones, whereas birds have only one. Furthermore, mammals have hair or fur covering their bodies, while birds have feathers. These structures perform different functions such as aiding in insulation against the environment and allowing for flight.\n",
      "\n",
      "In conclusion, while chickens share some characteristics with mammals, they are not classified as one due to significant anatomical and physiological differences. Despite their differences, both mammals and chickens are important members of the animal kingdom and contribute to their respective ecosystems.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": statement},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are an AI assistant specialized in solving riddles.\n",
    "Given a riddle, solve it the best you can.\n",
    "Provide a clear justification of your answer and the reasoning behind it.\n",
    "\n",
    "Riddle:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "riddle = \"\"\"\n",
    "What has a face and two hands, but no arms or legs?\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The answer to this riddle is a clock. \n",
      "\n",
      "A clock has a face with numbers and two hands (the hour and minute hand), which rotate around the center of the clock to show the time. Although it doesn't have any arms or legs like humans do, it still has the ability to measure time, which is important in our daily lives. \n",
      "\n",
      "Hence, a clock is the correct answer to this riddle.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": riddle},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Generate many output - self consistency"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are an AI assistant specialized in solving riddles.\n",
    "Given a riddle, you have to generate three answers to the riddle.\n",
    "For each answer, be specific about the reasoning you made.\n",
    "Then, among the three answer, select the one which is most plausible given the riddle.\n",
    "\n",
    "Riddle:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "riddle = \"\"\"\n",
    "There are four friends: Alice, Bob, Charlie, and David. They each have a different favorite color: red, blue, green, and yellow. They also each have a different favorite animal: cat, dog, fish, and bird. Using the following clues, can you figure out who likes what color and what animal?\n",
    "\n",
    "Alice does not like red or blue.\n",
    "Bob likes dogs, but not green.\n",
    "Charlie likes fish, but not yellow.\n",
    "David likes yellow, but not cats.\n",
    "The person who likes red also likes birds.\n",
    "The person who likes blue also likes cats.\n",
    "\n",
    "You can write your answer in the form of four sentences, such as “Alice likes green and fish.” \n",
    "\n",
    "\"\"\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are an AI assistant specialized in solving riddles.\n",
    "Given a riddle, you have to generate three answers to the riddle.\n",
    "For each answer, be specific about the reasoning you made.\n",
    "Then, among the three answer, select the one which is most plausible given the riddle.\n",
    "\n",
    "Riddle:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "riddle = \"\"\"\n",
    "What has a face and two hands, but no arms or legs?\n",
    "\n",
    "\"\"\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Answer 1: A clock. A clock has a face with numbers and two hands to show minutes and hours. It does not have arms or legs because it is an object, and it does not have intrinsic limbs.\n",
      "\n",
      "Answer 2: A watch. Similar to a clock, a watch also has a face with numbers and two hands to indicate the time. Although it is usually worn on a person's wrist, it does not have arms or legs.\n",
      "\n",
      "Answer 3: A wall. While this answer may be less obvious, a wall does, in a way, have a face and two hands. The face is its outer surface, and the hands are the clock that usually hangs on the wall. \n",
      "\n",
      "Among the three answers, the most plausible one is answer 1: a clock. The riddle distinctly mentions \"two hands\" and it's logical to associate hands with those that are found in clocks to indicate time.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": riddle},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Order Matters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are a sentiment analyzer. You classify conversations into three categories: positive, negative or neutral.\n",
    "Return only the sentiment, in lower cap and without punctuation.\n",
    "\n",
    "Conversation:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "conversation = \"\"\"\n",
    "Customer: Hi, I need some help with my order.\n",
    "AI agent: Hello, welcome to our online store. I'm an AI agent and I'm here to assist you. \n",
    "Customer: I ordered a pair of shoes yesterday, but I haven't received a confirmation email yet. Can you check the status of my order?\n",
    "AI agent: Sure, I can help you with that. Can you please provide me with your order number and email address?\n",
    "Customer: Yes, my order number is 123456789 and my email is john.doe@example.com.\n",
    "AI agent: Thank you. I have found your order in our system. It looks like your order is still being processed and it will be shipped soon. You should receive a confirmation email within 24 hours.\n",
    "Customer: OK, thank you for the information. How long will it take for the shoes to arrive?\n",
    "AI agent: You're welcome. According to our shipping policy, it will take about 3 to 5 business days for the shoes to arrive at your address. You can track your order online using the tracking number that will be sent to your email once your order is shipped.\n",
    "Customer: Alright, sounds good. Thank you for your help.\n",
    "AI agent: It's my pleasure. Is there anything else I can do for you today?\n",
    "Customer: No, that's all. Have a nice day.\n",
    "AI agent: Thank you for choosing our online store. Have a nice day too. Goodbye. \n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Neutral\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": conversation},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = f\"\"\"\n",
    "You are a sentiment analyzer. You classify conversations into three categories: positive, negative or neutral.\n",
    "Return only the sentiment, in lower cap and without punctuation.\n",
    "\n",
    "Conversation:\n",
    "{conversation}\n",
    "\n",
    "Remember to return only the sentiment, in lower cap and without punctuation!\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "neutral\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"user\", \"content\": system_message},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "text = \"\"\"\n",
    "A neutron is a subatomic particle that has a neutral (not positive or negative) charge, and a mass slightly greater than that of a proton. \n",
    "It is present in all atomic nuclei except those of ordinary hydrogen. \n",
    "Neutrons, along with protons and electrons, are one of the three basic particles making up atoms. \n",
    "The term “neutron” comes from the fact that it is electrically neutral, meaning it carries no charge.\n",
    "\"\"\"\n",
    "\n",
    "system_message = f\"\"\"\n",
    "Reframe the text for a 5 years old child. It should be shorter than 500 words. Make a parallelism with animals.\n",
    "\n",
    "The text is the following:\n",
    "\n",
    "{text}\n",
    "\n",
    "\"\"\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A neutron is a teeny tiny speck that makes up everything around us, like little puzzle pieces. It's like a super quiet animal that lives inside of atoms along with other animals called protons and electrons. It doesn't like to show off and doesn't have any electric charge, like it's wearing a special invisible cloak. But without neutrons, everything would be different like a zoo without one of its animals.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"user\", \"content\": system_message},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use delimiters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are a Python expert that produces python code as per user's request.\n",
    "\n",
    "===>START EXAMPLE\n",
    "\n",
    "---User Query---\n",
    "Give me a function to print a string of text.\n",
    "\n",
    "---User Output---\n",
    "Below you can find the described function:\n",
    "```def my_print(text):\n",
    "     return print(text)\n",
    "```\n",
    "<===END EXAMPLE\n",
    "\"\"\"\n",
    "\n",
    "query = \"generate a python function to calculate the nth Fibonacci number\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sure, here's a Python function to calculate the nth Fibonacci number:\n",
      "\n",
      "```python\n",
      "def fibonacci(n):\n",
      "    if n < 0:\n",
      "        return None\n",
      "    elif n == 0:\n",
      "        return 0\n",
      "    elif n == 1:\n",
      "        return 1\n",
      "    else:\n",
      "        return fibonacci(n-1) + fibonacci(n-2)\n",
      "```\n",
      "\n",
      "The function takes a non-negative integer `n` as input and returns the nth Fibonacci number. If `n` is less than 0, the function returns `None`. If `n` is 0 or 1, the function returns the value of `n`. In all other cases, the function recursively calls itself with `n-1` and `n-2` and adds their results to compute the nth Fibonacci number.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": query},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Few shot learning"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are an AI marketing assistant. You help users to create taglines for new product names.\n",
    "Given a product name, produce a tagline similar to the following examples:\n",
    "\n",
    "Peak Pursuit - Conquer Heights with Comfort\n",
    "Summit Steps - Your Partner for Every Ascent\n",
    "Crag Conquerors - Step Up, Stand Tal\n",
    "\n",
    "Product name:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "product_name = 'Elevation Embrace'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tagline idea: Embrace the Heights with Confidence.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": product_name},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>I grew up (b. 1965) watching and loving the Th...</td>\n",
       "      <td>Negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>When I put this movie in my DVD player, and sa...</td>\n",
       "      <td>Negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Why do people who do not know what a particula...</td>\n",
       "      <td>Negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Even though I have great interest in Biblical ...</td>\n",
       "      <td>Negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Im a die hard Dads Army fan and nothing will e...</td>\n",
       "      <td>Positive</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                text     label\n",
       "0  I grew up (b. 1965) watching and loving the Th...  Negative\n",
       "1  When I put this movie in my DVD player, and sa...  Negative\n",
       "2  Why do people who do not know what a particula...  Negative\n",
       "3  Even though I have great interest in Biblical ...  Negative\n",
       "4  Im a die hard Dads Army fan and nothing will e...  Positive"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "df = pd .read_csv('movie.csv', encoding='utf-8')\n",
    "df['label'] = df['label'].replace({0: 'Negative', 1: 'Positive'})\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>32823</th>\n",
       "      <td>The central theme in this movie seems to be co...</td>\n",
       "      <td>Negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16298</th>\n",
       "      <td>An excellent example of \"cowboy noir\", as it's...</td>\n",
       "      <td>Positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28505</th>\n",
       "      <td>The ending made my heart jump up into my throa...</td>\n",
       "      <td>Negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6689</th>\n",
       "      <td>Only the chosen ones will appreciate the quali...</td>\n",
       "      <td>Positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26893</th>\n",
       "      <td>This is a really funny film, especially the se...</td>\n",
       "      <td>Positive</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    text     label\n",
       "32823  The central theme in this movie seems to be co...  Negative\n",
       "16298  An excellent example of \"cowboy noir\", as it's...  Positive\n",
       "28505  The ending made my heart jump up into my throa...  Negative\n",
       "6689   Only the chosen ones will appreciate the quali...  Positive\n",
       "26893  This is a really funny film, especially the se...  Positive"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.sample(n=10, random_state=42)  # Change the value of 'random_state' as needed for reproducibility\n",
    "df.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "You are a binary classifier for sentiment analysis.\n",
    "Given a text, based on its sentiment you classify it into one of two categories: positive or negative.\n",
    "\n",
    "You can use the following texts as examples:\n",
    "\n",
    "Text: \"I love this product! It's fantastic and works perfectly.\"\n",
    "Positive\n",
    "\n",
    "Text: \"I'm really disappointed with the quality of the food.\"\n",
    "Negative\n",
    "\n",
    "Text: \"This is the best day of my life!\"\n",
    "Positive\n",
    "\n",
    "Text: \"I can't stand the noise in this restaurant.\"\n",
    "Negative\n",
    "\n",
    "ONLY return the sentiment as output (without punctuation).\n",
    "\n",
    "Text:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "text = \"The concert was amazing! The band was incredible!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Positive\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": text},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                                    text     label predicted\n",
      "32823  The central theme in this movie seems to be co...  Negative  Negative\n",
      "16298  An excellent example of \"cowboy noir\", as it's...  Positive  Positive\n",
      "28505  The ending made my heart jump up into my throa...  Negative  Positive\n",
      "6689   Only the chosen ones will appreciate the quali...  Positive  Positive\n",
      "26893  This is a really funny film, especially the se...  Positive  Positive\n",
      "36572  Sure, we all like bad movies at one time or an...  Negative  Negative\n",
      "12335  Why?!! This was an insipid, uninspired and emb...  Negative  Negative\n",
      "29591  This is one of those movies that has everythin...  Positive  Positive\n",
      "18948  i saw this film over 20 years ago and still re...  Positive  Positive\n",
      "31067  This true story of Carlson's Raiders is more o...  Negative  Negative\n"
     ]
    }
   ],
   "source": [
    "\n",
    "def process_text(text):\n",
    "    response = openai.ChatCompletion.create(\n",
    "        engine=\"gpt-3.5-turbo\", \n",
    "        messages=[\n",
    "            {\"role\": \"system\", \"content\": system_message},\n",
    "            {\"role\": \"user\", \"content\": text},\n",
    "        ]\n",
    "    )\n",
    "    return response['choices'][0]['message']['content']\n",
    "\n",
    "df['predicted'] = df['text'].apply(process_text)\n",
    "\n",
    "print(df)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text</th>\n",
       "      <th>label</th>\n",
       "      <th>predicted</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>32823</th>\n",
       "      <td>The central theme in this movie seems to be co...</td>\n",
       "      <td>Negative</td>\n",
       "      <td>Negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16298</th>\n",
       "      <td>An excellent example of \"cowboy noir\", as it's...</td>\n",
       "      <td>Positive</td>\n",
       "      <td>Positive.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28505</th>\n",
       "      <td>The ending made my heart jump up into my throa...</td>\n",
       "      <td>Negative</td>\n",
       "      <td>Positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6689</th>\n",
       "      <td>Only the chosen ones will appreciate the quali...</td>\n",
       "      <td>Positive</td>\n",
       "      <td>Positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26893</th>\n",
       "      <td>This is a really funny film, especially the se...</td>\n",
       "      <td>Positive</td>\n",
       "      <td>Positive</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    text     label  predicted\n",
       "32823  The central theme in this movie seems to be co...  Negative   Negative\n",
       "16298  An excellent example of \"cowboy noir\", as it's...  Positive  Positive.\n",
       "28505  The ending made my heart jump up into my throa...  Negative   Positive\n",
       "6689   Only the chosen ones will appreciate the quali...  Positive   Positive\n",
       "26893  This is a really funny film, especially the se...  Positive   Positive"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## CoT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "system_message = \"\"\"\n",
    "To solve a generic first-degree equation, follow these steps:\n",
    "\n",
    "1. **Identify the Equation:** Start by identifying the equation you want to solve. It should be in the form of \"ax + b = c,\" where 'a' is the coefficient of the variable, 'x' is the variable, 'b' is a constant, and 'c' is another constant.\n",
    "\n",
    "2. **Isolate the Variable:** Your goal is to isolate the variable 'x' on one side of the equation. To do this, perform the following steps:\n",
    "   \n",
    "   a. **Add or Subtract Constants:** Add or subtract 'b' from both sides of the equation to move constants to one side.\n",
    "   \n",
    "   b. **Divide by the Coefficient:** Divide both sides by 'a' to isolate 'x'. If 'a' is zero, the equation may not have a unique solution.\n",
    "\n",
    "3. **Simplify:** Simplify both sides of the equation as much as possible.\n",
    "\n",
    "4. **Solve for 'x':** Once 'x' is isolated on one side, you have the solution. It will be in the form of 'x = value.'\n",
    "\n",
    "5. **Check Your Solution:** Plug the found value of 'x' back into the original equation to ensure it satisfies the equation. If it does, you've found the correct solution.\n",
    "\n",
    "6. **Express the Solution:** Write down the solution in a clear and concise form.\n",
    "\n",
    "7. **Consider Special Cases:** Be aware of special cases where there may be no solution or infinitely many solutions, especially if 'a' equals zero.\n",
    "\n",
    "\n",
    "Equation:\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "equation = \"3x + 5 = 11\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1. Identify the Equation: The equation is 3x + 5 = 11.\n",
      "\n",
      "2. Isolate the Variable:\n",
      "   \n",
      "   a. Subtract Constants: Subtract 5 from both sides to move constants to one side: \n",
      "   \n",
      "      3x + 5 - 5 = 11 - 5 \n",
      "   \n",
      "   Simplifying, we get:\n",
      "   \n",
      "      3x = 6\n",
      "   \n",
      "   b. Divide by the Coefficient: Divide both sides by 3 to isolate 'x':\n",
      "   \n",
      "      3x/3 = 6/3\n",
      "   \n",
      "   Simplifying, we get:\n",
      "   \n",
      "      x = 2\n",
      "   \n",
      "3. Simplify: Both sides are already simplified.\n",
      "\n",
      "4. Solve for 'x': x = 2.\n",
      "\n",
      "5. Check Your Solution: Plug x = 2 back into the original equation:\n",
      "\n",
      "   3(2) + 5 = 11\n",
      "   \n",
      "   Simplifying, we get:\n",
      "   \n",
      "   6 + 5 = 11\n",
      "   \n",
      "   The left side equals the right side, so the solution is correct.\n",
      "\n",
      "6. Express the Solution: The solution to the equation 3x + 5 = 11 is x = 2.\n",
      "\n",
      "7. Consider Special Cases: Since the coefficient 3 is not zero, there are no special cases to consider.\n"
     ]
    }
   ],
   "source": [
    "response = openai.ChatCompletion.create(\n",
    "    engine=\"gpt-3.5-turbo\", # engine = \"deployment_name\".\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": system_message},\n",
    "        {\"role\": \"user\", \"content\": equation},\n",
    "    ]\n",
    ")\n",
    "\n",
    "#print(response)\n",
    "print(response['choices'][0]['message']['content'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ReAct"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.environ[\"OPENAI_API_TYPE\"] = \"azure\"\n",
    "os.environ[\"OPENAI_API_VERSION\"] = \"2023-05-15\"\n",
    "os.environ[\"OPENAI_API_BASE\"] = \"https://openaivaalt.openai.azure.com/\"\n",
    "os.environ[\"OPENAI_API_KEY\"] = \"8d236d7c6ed945ddb80358800bd2866c\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "from langchain import SerpAPIWrapper\n",
    "from langchain.agents import AgentType, initialize_agent\n",
    "from langchain.chat_models import AzureChatOpenAI\n",
    "from langchain.tools import BaseTool, StructuredTool, Tool, tool\n",
    "# Import Azure OpenAI\n",
    "from langchain.llms import AzureOpenAI\n",
    "from langchain.schema import HumanMessage\n",
    "\n",
    "model = AzureChatOpenAI(\n",
    "    deployment_name='gpt-3.5-turbo',\n",
    "    openai_api_type=\"azure\",\n",
    ")\n",
    "\n",
    "model(\n",
    "    [\n",
    "        HumanMessage(\n",
    "            content=\"Translate this sentence from English to French. I love programming.\"\n",
    "        )\n",
    "    ]\n",
    ")\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "key = os.environ[\"SERPAPI_API_KEY\"]\n",
    "\n",
    "search = SerpAPIWrapper()\n",
    "tools = [\n",
    "    Tool.from_function(\n",
    "        func=search.run,\n",
    "        name=\"Search\",\n",
    "        description=\"useful for when you need to answer questions about current events\"\n",
    "    )\n",
    "    ]\n",
    "\n",
    "agent_executor = initialize_agent(tools, model, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Answer the following questions as best you can. You have access to the following tools:\n",
      "\n",
      "Search: useful for when you need to answer questions about current events\n",
      "\n",
      "Use the following format:\n",
      "\n",
      "Question: the input question you must answer\n",
      "Thought: you should always think about what to do\n",
      "Action: the action to take, should be one of [Search]\n",
      "Action Input: the input to the action\n",
      "Observation: the result of the action\n",
      "... (this Thought/Action/Action Input/Observation can repeat N times)\n",
      "Thought: I now know the final answer\n",
      "Final Answer: the final answer to the original input question\n",
      "\n",
      "Begin!\n",
      "\n",
      "Question: {input}\n",
      "Thought:{agent_scratchpad}\n"
     ]
    }
   ],
   "source": [
    "print(agent_executor.agent.llm_chain.prompt.template)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3mI should search for recent news or updates about the Italian male athletes for climbing at the Paris 2024 Olympics\n",
      "Action: Search\n",
      "Action Input: \"Italian male athletes climbing Paris 2024 Olympics\"\u001b[0m\n",
      "Observation: \u001b[36;1m\u001b[1;3mA select group of climbers ensured their participation in the 2024 Paris Olympics. Among them, Italy's Matteo Zurloni and Indonesia's Desak Made Rita Kusuma Dewi didn't just secure their Olympic berths; they also took home the world titles in their respective categories.\u001b[0m\n",
      "Thought:\u001b[32;1m\u001b[1;3mI need to refine my search to find a more comprehensive list of Italian male climbers for Paris 2024 Olympics\n",
      "Action: Search\n",
      "Action Input: \"List of Italian male climbers Paris 2024 Olympics\"\u001b[0m\n",
      "Observation: \u001b[36;1m\u001b[1;3mItaly fielded a squad of five male gymnasts for Paris after advancing to the final round ... Paris 2024 qualification berths, and medals table - complete list\".\u001b[0m\n",
      "Thought:\u001b[32;1m\u001b[1;3mThis information does not seem to be readily available, I should try contacting the Italian climbing federation for more information\n",
      "Action: Search\n",
      "Action Input: \"contact information for Italian climbing federation\"\u001b[0m\n",
      "Observation: \u001b[36;1m\u001b[1;3mIFSC HEADQUARTERS: Corso Vinzaglio 12 10121, Torino, ITALY. Opening Hours: Monday - Friday 9:00 AM - 5:00 PM CEST. IFSC OFFICE:.\u001b[0m\n",
      "Thought:\u001b[32;1m\u001b[1;3mI can reach out to the Italian climbing federation to ask for a list of their male athletes participating in the Paris 2024 Olympics\n",
      "Action: Contact\n",
      "Action Input: Email or phone call to the Italian climbing federation requesting information on the male athletes for Paris 2024 Olympics\u001b[0m\n",
      "Observation: Contact is not a valid tool, try one of [Search].\n",
      "Thought:\u001b[32;1m\u001b[1;3mI will refine my search further to see if any new information has been released about the Italian male climbers for the Paris 2024 Olympics\n",
      "Action: Search\n",
      "Action Input: \"Latest updates on Italian male climbers for Paris 2024 Olympics\"\u001b[0m\n",
      "Observation: \u001b[36;1m\u001b[1;3mAleksandra Miroslaw and Bassa Mawem have secured quota spots to next summer's Paris 2024 Olympic Games following respective wins at the IFSC ...\u001b[0m\n",
      "Thought:\u001b[32;1m\u001b[1;3mBased on the information I have gathered, it seems that there is no comprehensive list of Italian male climbers for the Paris 2024 Olympics readily available. However, I do know that Matteo Zurloni is one of the Italian male climbers who has secured a spot at the Olympics. \n",
      "Final Answer: Matteo Zurloni is one of the Italian male climbers who has secured a spot at the Paris 2024 Olympics, but a comprehensive list of Italian male climbers for the Olympics is not readily available.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'input': 'who are going to be the italian male athletes for climbing at the Paris 2024 Olympics?',\n",
       " 'output': 'Matteo Zurloni is one of the Italian male climbers who has secured a spot at the Paris 2024 Olympics, but a comprehensive list of Italian male climbers for the Olympics is not readily available.'}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent_executor('who are going to be the italian male athletes for climbing at the Paris 2024 Olympics?')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
